package com.kehutong.tag.entity;

import com.kehutong.crm.enums.TagSourceType;
import org.coraframework.bean.valid.CheckField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;

import java.util.List;
import java.util.Set;

/**
 * 自定义标签
 */
@Table(value="t_customize_tag", comment="自定义标签", multi=true)
public class CustomizeTag extends Entity{

	private static final long serialVersionUID = 4177501639936105917L;

	protected CustomizeTag(String id) {
        super(id);
    }

    @CheckField("上级标签不能为空")
    @Column(length = 64, comment = "上级标签")
    private String pid;

	@UnSave
    private String pname;

    @CheckField("名称不能为空")
	@Column(comment = "标签名称")
    private String  name;

    @Column(comment="标签来源类型")
    private TagSourceType type;

    @Column(comment = "标签描述")
    private String desc;
	
	@Column(comment = "是否标签组")
	private boolean group;

    @Column(comment = "状态：0禁用，1启用")
    private boolean status;

    @Column(comment = "使用数量")
    private long useCount;

    @Column(comment = "排序")
    private long sort;

    @Column(comment = "逻辑删除")
    private boolean deleted;

    @Column(comment="创建人")
    private String createBy;

    @Column(comment = "创建人名字")
    private String createName;

    @Column(comment="共创人")
    private List<String> commonCreateBy;

    @Column(comment="共创人名称")
    private List<String> commonCreateName;

    @UnSave
    private List<CustomizeTag> childList;

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public boolean isGroup() {
        return group;
    }

    public void setGroup(boolean group) {
        this.group = group;
    }

    public long getUseCount() {
        return useCount;
    }

    public void setUseCount(long useCount) {
        this.useCount = useCount;
    }

    public long getSort() {
        return sort;
    }

    public void setSort(long sort) {
        this.sort = sort;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public List<CustomizeTag> getChildList() {
        return childList;
    }

    public void setChildList(List<CustomizeTag> childList) {
        this.childList = childList;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        CustomizeTag customizeTag = (CustomizeTag) o;

        if (group != customizeTag.group) return false;
        return pid.equals(customizeTag.pid);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + pid.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + (group ? 1 : 0);
        return result;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public List<String> getCommonCreateBy() {
        return commonCreateBy;
    }

    public void setCommonCreateBy(List<String> commonCreateBy) {
        this.commonCreateBy = commonCreateBy;
    }

    public List<String> getCommonCreateName() {
        return commonCreateName;
    }

    public void setCommonCreateName(List<String> commonCreateName) {
        this.commonCreateName = commonCreateName;
    }

    public TagSourceType getType() {
        return type;
    }

    public void setType(TagSourceType type) {
        this.type = type;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }
}